#!/bin/perl 


my @mapping = (
    ['-'],
    ['a','b','c'],
    ['d','e','f'],
    ['g','h','i'],
    ['j','k','l'],
    ['m','n','o'],
    ['p','q','r','s'],
    ['t','u','v'],
    ['x','y','z']
);


my $result = all_possible($ARGV[0]);
print join("\n",@$result);

sub all_possible {
    my $num = shift;
    my $n = substr($num,0,1);
    my $s = substr($num,1);
    my $n_choice = $mapping[$n];
    return $n_choice if $s eq '';
    my @result = ();
    my $ref = all_possible($s);
    foreach my $i (@$n_choice) {
        my @list = @$ref;
        map {$_ = $i.$_;} @list;
        push @result,@list;
    }
    return \@result;
}
